-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Integrate pre-commit #11603
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integrate pre-commit #11603
Conversation
|
Looks like |
f99c73f to
062d3cf
Compare
|
I've already tried twice to propose PR to integrate pre-commits and they were all refused because involving "too much changes" my last one (that you linked) is creating the file itself but only runs ruff. Can someone provides review there ? That's already the second time that I try to contribute to sphinx and that my PR is closed because overridden by someone else. Is it common practice here ? if yes I'll stop trying and will simply open well documented issues. |
It's not common practice. However, you've overloaded the PRs in all cases. Rather than just focusing on simply integrating a new tool, the PRs have also reformatted the entire code base with a different tool (#11251) or changed the rules for an existing linter (#11375). I suspect you'd have more luck if you tackled these topics in separate PRs. |
Useful for linters. Signed-off-by: Stephen Finucane <[email protected]>
Signed-off-by: Stephen Finucane <[email protected]>
Signed-off-by: Stephen Finucane <[email protected]>
Signed-off-by: Stephen Finucane <[email protected]>
This is unnecessary duplication that isn't used anywhere. Signed-off-by: Stephen Finucane <[email protected]>
|
@AA-Turner I don't want to merge this without getting your agreement on this, given the imbalance in number of contributions of late. As such, could I get your ack on this? fwict, you're using a local virtual environment to (presumably) enable IDE integration? If so, this should have no significant impact for you. I suspect the only real change would be whenever we want to bump a linter version we would now update the pacakge version in |
I use a single conda environment (through the
If I make no changes, yes, though I feel that contributors ought adopt the guidelines set out by the project, so I'd feel obliged to change to using The only reason I don't use A |
For me at least, the main benefit is that linting becomes an automated thing rather than something run as an afterthought (or not at all). You can opt to ignore the linting step (pass
Do we? I mean, does it matter if you use conda and I use Now if we were proposing a process that no one ran, that's different, but this is slotted into our CI so we are dogfooding this process.
5-15 seconds seems exceptionally long. fwiw
gtk. From a Linux user's perspective it is obviously very useful, so thank you for keeping it around. |
|
Although I thinking linting and enforcement of code style using continuous integration, I often feel a bit conflicted about (I tend to use To try to make that feedback more relevant here: I'd personally prefer if this were opt-in by default rather than opt-out. |
It is opt-in, no? You need to install the tool itself and configure it in your local repo before anything will happen. If you opt to install the linters locally instead, that's a-okay. |
At the end of the day for a PR to be validated, you need to comply with the ruff checks, so what tool choices do you have ? pre-commit only brings to your local development the linting operation that are/should be tested in the CI. |
|
I'm probably being too stubborn - it was the mention of "(pass -n to As for alternatives: there are many linters, but there's only one And to be honest: sometimes I do just code a fix (or equally often, poor attempt at one) and then lean on continuous integration to catch problems. That's more likely in cases where I don't totally trust the install processes for the continuous integration components. |
Ah yes, the
So you can completely ignore this if you like. I'll update the PR text.
Indeed. It's important to note, however, that pre-commit is just a runner of existing linters and of course
That's a-okay, but of course not everyone works like that however. This PR at least provides an option for the latter folks. |
|
To be clear, I want to re-add the ability to install and run the correct version of all our linters with one command. As far as I'm aware, our three options here are pre-commit, tox, and nox. I have a preference for pre-commit since it's can be automatic (if installed) and is easily wrapped by tox as I've done here, but I will settle for any of the three. However, whatever tool we settle on should be used by CI to prevent it going stale. |
|
I'm keeping an eye on this thread, as introducing a standardised command mechanism would meet the goal of running a single command and mean that using pre-commit is still optional. We may also get this 'for free' if we switch to A |
Feature or Bugfix
Refactoring
Purpose
Integrate
pre-commitfor linting. This is an exceptionally useful tool that provides a mechanism to automate all sorts of linters, including all of those that we currently support and rely on. It can also be used as a standalone tool, as demonstrated by the GitHub Workflows used within.This change also adds a
linttox environment, which is simply a wrapper aroundpre-commit(for those used to this workflow), and migrates the various linter-related GitHub Action steps to usepre-commit. The latter is important since without this, configurations will drift. Developers who wish to configure their environment manually or in a different manner can continue to do so, but the vast majority can benefit from automated linting and fixing.As a future change, we may wish to integrate pre-commit.ci since that will automate the fixing of PRs using pre-commit (currently we just check if they would require fixes) but that's a separate issue.
Detail
This is an alternative to #11602 and potentially #11375. It resolves #11205.
Relates
linttarget #11602